<?php require_once('../Connections/locale.php'); ?>
<?php
mysql_select_db($database_locale, $locale);
$query_stati = "SELECT * FROM stati";
$stati = mysql_query($query_stati, $locale) or die(mysql_error());
$row_stati = mysql_fetch_assoc($stati);
$totalRows_stati = mysql_num_rows($stati);

mysql_select_db($database_locale, $locale);

?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>elenco stati</title>
<link href="../style.css" rel="stylesheet" type="text/css" />
</head>

<body>
<table border="1" id="datatable">
  <tr>
    <td>ID</td>
    <td>Nome Stato</td>
    <td>Sigla Stato</td>
	<td><a href="inserisci_stato.php"><img src="../images/page.gif" alt="Nuovo Elemento" width="18" height="18" border="0" /></a></td>
	<td></td>
  </tr>
  <?php do { ?>
    <tr>
      <td><?php echo $row_stati['id_stato']; ?></td>
      <td><?php echo $row_stati['nome_stato']; ?></td>
      <td><?php echo $row_stati['sigla_stato']; ?></td>
	  <td><a href="modifica_stato.php?id_stato=<?php echo $row_stati['id_stato']; ?>"><img src="../images/modifica.png" alt="Modifica" width="16" height="16" border="0" /></a></td>
	  <td><?php 
	  $query_legami_regioni = "SELECT * FROM regioni WHERE id_stato =".$row_stati['id_stato'];
$legami_regioni = mysql_query($query_legami_regioni, $locale) or die(mysql_error());
$row_legami_regioni = mysql_fetch_assoc($legami_regioni);
$totalRows_legami_regioni = mysql_num_rows($legami_regioni);
	  
	  if ($totalRows_legami_regioni == 0) { // Show if recordset empty ?>
	      <img src="../images/elimina.png" alt="Elimina" width="16" height="16" />
	      <?php } // Show if recordset empty ?></td>    
	</tr>
    <?php } while ($row_stati = mysql_fetch_assoc($stati)); ?>
</table>
</body>
</html>
<?php
mysql_free_result($stati);

mysql_free_result($legami_regioni);
?>
